Create a Custom Node from a MATLAB Simulink model

You can generate a DLL file for a Custom Node DLL from a TPT test frame model using the Simulink Coder or Embedded Coder. The so generated MATLAB FUSION DLL can then be applied to a Custom Node DLL, to run tests on the MATLAB/Simulink model.

Preconditions and constraints

Build a MATLAB/Simulink model for FUSION

To create the MATLAB FUSION DLL, configure a MATLAB/Simulink Platform and click the Build model for FUSION button under Tools in the MATLAB/Simulink Platform Configuration dialog. This will generate a temporary model and trigger the code generation via the Simulink Coder or Embedded Coder. A message box appears. Click Yes if you want to create the FUSION Platform using the previously generated MATLAB FUSION DLL.

If you generate a DLL from a MATLAB/Simulink model, MATLAB 32/64-bit versions will generate a 32/64-bit DLL file respectively.
If the Natively use bus/enumeration/fixed-point data types specified by SUT checkbox in the Import Interface section of the Platform Configuration dialog is enabled and array-of-bus-/enum- or fixed-point data types exist in the interface of the SUT subsystem this feature is not supported.

Build a DLL from a MATLAB model

The generated MATLAB FUSION DLL provides access to online loggings as channels and offline loggings as measurements. Additionally, an Import Measurement assesslet, see Assesslet Types - Import Measurements, is automatically created when adding offline loggings as internal signals via the MATLAB/Simulink Platform configuration. This assesslet will not work when using the generated MATLAB FUSION DLL within a FUSION Platform.

To prevent an execution error on test execution, set the Execution Context of the Import Measurement assesslet to MATLAB/Simulink Platform, see Common Assesslet Settings - Execution Context, or delete the assesslet.

Create a MATLAB/Simulink model for FUSION only

If you want to adjust the model manually before the code generation, select Create model for FUSION only. In this case, you need to build the generated model manually. TPT provides two targets/profiles for the Simulink Coder: fusion_grt.tlc and fusion_ert.tlc. The former one is based on the Simulink Coder's GRT target (grt.tlc); the latter one is based on the Embedded Coder's ERT target (ert.tlc). Both TPT targets automatically generate a FUSION Platformcompliant interface to the function or model into a DLL, combined with the model's code.

Generate the code with Simulink Coder/Embedded Coder

To manually generate the code with Simulink Coder / Embedded Coder, go to "Code Generation options" and another "System target file" in the "Target Selection" section.

Code generation

  1. Go to "TPT options" and check the TPT installation path. It should have been set automatically when starting MATLAB from within TPT. However, it is possible to select a TPT installation or to manually edit the installation path.
  2. TPT options

  3. Click "Build" in the "Code Generation" section to start the generation of the MATLAB FUSION DLL. Make sure the option "Generate code only" is disabled.
In the Simulink Coder, matrices are handled as arrays.

Model parameters which will be exchanged between TPT and MATLAB FUSION DLL must be Simulink Parameter objects or they have to be declared in Simulink as global / tunable parameter. Go to "Optimization|Signals and Parameters" in the model settings in Simulink to make changes.

In case you experience any problems with the fusion_grt.tlc or fusion_ert.tlc targets, try generating code with grt.tlc or ert.tlc first to make sure your model is ready for code/DLL generation.

Naming conventions for in- and outputs

Apply the MATLAB FUSION DLL to a Custom Node

  1. Create a FUSION Platform.
  2. Add a Custom Node DLL.
  3. Select the MATLAB FUSION DLL in the Node DLL field.
The MATLAB FUSION DLL is placed next to the test frame.

Custom node settings for MATLAB FUSION DLL

The MATLAB FUSION DLL accepts three different arguments:

-pv

output of all FUSION Platformvariables (inputs, outputs, model parameter) related to your model with name, data type and so forth at the beginning of the test execution in the Build Progress dialog

-pc

output of the complete variable usage (read/write) of the FUSION Platformexecution in the Build Progress dialog

-timeout <n>

response timeout in seconds for the functions of the FUSION node interface, see FUSION Programmers Guide - tpt_fusion_setFcnResponseTimeOut()

The default FUSION Platform timeout value is 10s. The value can be changed. For example, to increase the value from 10s to 20s enter -timeout 20.